﻿@{
    Layout = null;
}
<head>
    <title>权限分配</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/css/style.css" />
    <link href="~/css/img.css" rel="stylesheet" />
</head>
<body class="bb1">
    <div align=center class="d1">
        <marquee style="FONT-SIZE: 35pt; WIDTH: 400px; FILTER: shadow(color=#AF0530); LINE-HEIGHT:15pt; FONT-FAMILY: 隶书; HEIGHT: 80px" scrollamount=6>
            <h2 style="margin-top:0px;text-align:center"><font color=#f90b46>分配权限 </font></h2>
        </marquee>
    </div>
    <div class="page-container">
        <table class="table table-border table-bordered table-hover table-bg">
            <tr class="text-c">
                <td width="50" ><input type="checkbox" id="check" onclick="AllChecked()" />全选</td>
                <td></td>
            </tr>
            <tr class="text-c">
                <td width="50" >角色：</td>
                <td><select style="width:200px;text-align:center" id="selected"><option value="1">管理员</option><option value="2">录入员</option><option value="3">维修工</option><option value="4">科长</option><option value="5">局长</option></select></td>
            </tr>
            <tr class="text-c">
                <td width="70" >选择权限：</td>
                <td width="69%">
                    @foreach (var item in Model)
                    {

                        <input type="checkbox" name="checkid" class="mm" value="@item.PermissionId" />@item.PermissionName

                    }
                </td>
            </tr>
            <tr class="text-c">
                <td colspan="2"><a class="btn btn-primary radius" onclick="FenPei()" href="javascript:;"><i class="Hui-iconfont"></i> 分配</a></td>
            </tr>
        </table>
        <footer class="footer mt-20">
            <div class="container">
                <p>
                    关于我们  |  联系我们    |  项目合作  |  广告植入   |  友情链接<br />
                    版权所有 京ICP备11009069<br />
                    Copyright ©2016 Gaotie.cn
                </p>
            </div>
        </footer>
    </div>
</body>
<script type="text/javascript" src="~/H-ui.admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="~/H-ui.admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="~/H-ui.admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="~/H-ui.admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="~/H-ui.admin/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript">
        function AllChecked() {
            var ck = document.getElementById("check").checked;

            var k = document.getElementsByName("checkid");
            for (var c in k) {
                k[c].checked = ck;

            }
        }

    function FenPei() {
        var id = "";
        for (var i = 0; i < $(".mm").length; i++)
        {
            if($(".mm").eq(i).attr("checked")=="checked")
            {
                id += $(".mm").eq(i).val() + ",";
            }
        }
        if (id.length==0) {
            alert('至少选择一个')
            return;
        }
        else {
            var selected = $("#selected").val();
            $.ajax({
                type: "post",
                url: "/Home/AddPermisson",
                data: { id: id, selected: selected },
                success: function (obj) {
                    if (obj > 0) {
                        alert('分配成功')
                        location.href="/Home/AllotPermission"
                        return;
                    }
                    alert('分配失败')
                }
            })
        }
    }
</script>